function e(e, t) {
    if (e && t) {
        for (var a = e.split("."), o = t.split("."), n = Math.min(a.length, o.length), i = 0, d = 0; i < n && 0 == (d = parseInt(a[i]) - parseInt(o[i])); ) i++;
        return (d = 0 != d ? d : a.length - o.length) >= 0;
    }
    return console.log("版本号不能为空"), !1;
}

var t, a = function(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}(require("../../../utils/tools.js"));

getApp();

Page({
    data: {
        pageName: "mine",
        invite_red_show: !1,
        request: 1,
        showSell: !1,
        videoAd1: "",
        hasvideoAd1: !1,
        audit_model: !1,
        ad_load: !1
    },
    onLoad: function(e) {
        t = this;
    },
    onReady: function() {
        var o = {
            action: "index",
            contr: "my",
            token: wx.getStorageSync("token")
        };
        a.default.request(o, function(a) {
			var item = {
				"pageName": "tx",
				"text": "探险",
				"iconPath": "https://www.shangjinya.com/addons/bh_farm/template/static/images/xcx/a17.png",
				"selectedIconPath": "https://www.shangjinya.com/addons/bh_farm/template/static/images/xcx/a15.png",
				"index": 1,
				"visible": true
			}
			var tabs = a.info.list
			var newTabs = [tabs[0],item, tabs[3], tabs[4]]
			a.info.list = newTabs
            t.setData(a.info);
            var o = wx.getSystemInfoSync();
            console.log(6969696), t.data.videoAd1 = null, console.log(a.info.adUnitId), console.log(e(o.SDKVersion, "2.0.4")), 
            a.info.adUnitId && e(o.SDKVersion, "2.6.0") && (console.log(99995841), t.data.videoAd1 = wx.createRewardedVideoAd({
                adUnitId: a.info.adUnitId
            }), t.setData({
                ad_load: !0
            }));
        });
    },
    hideInviteRed: function() {
        this.setData({
            invite_red_show: !1
        });
    },
    showInviteRed: function() {
        this.setData({
            invite_red_show: !0
        });
    },
    hideSell: function() {
        this.setData({
            showSell: !1
        });
    },
    onSellEgg: function() {
        this.setData({
            showSell: !0
        });
    },
    openRed: function(e) {
        var o = e.currentTarget.dataset.index, n = {
            action: "shareBag",
            contr: "water",
            token: wx.getStorageSync("token"),
            index: o
        };
        1 == t.data.request && (t.data.request = 2, a.default.request(n, function(e) {
            t.data.request = 1, 1 == e.status ? t.setData(e.info) : wx.showModal({
                title: "提示",
                mask: !0,
                content: e.info,
                showCancel: !1
            });
        }));
    },
    exchange: function() {
        var e = {
            action: "exchange",
            contr: "fruit",
            token: wx.getStorageSync("token")
        };
        1 == t.data.request && (t.data.request = 2, a.default.request(e, function(e) {
            t.data.request = 1, t.setData({
                showSell: !1
            }), 1 == e.status ? t.onReady() : wx.showModal({
                title: "提示",
                mask: !0,
                content: e.info,
                showCancel: !1
            });
        }));
    },
    onUnload: function() {
        console.log(888), t.data.videoAd1;
    },
    onHide: function() {
        console.log(8885), t.data.videoAd1;
    },
    video1AdShow: function(e) {
        var a = this;
        this.data.videoAd1 && (this.data.videoAd1.show(), this.data.videoAd1.onClose(function(e) {
            a.data.videoAd1.offClose(), (e && e.isEnded || void 0 === e) && t.exchange();
        }));
    },
    onShow: function() {},
    gotoTelephoneBill: function() {
        wx.navigateTo({
            url: "/bh_farm/pages/exchange/exchange"
        });
    },
    gotoOrder: function() {
        wx.navigateTo({
            url: "/bh_farm/pages/order/order"
        });
    },
    gotoGoods: function() {
        wx.navigateTo({
            url: "/bh_farm/pages/goods/goods"
        });
    },
    navigatorSwitch: function(e) {
        console.log(e.detail.pageName);
        var t = e.detail.pageName;
        if (t != this.data.pageName) {
            if ("index" == t) a = "/bh_farm/pages/index/index";else if ("tx" == t) a = "/bh_farm/pages/tx/tx"; else if ("recruit" == t) a = "/bh_farm/pages/recruit/recruit"; else if ("pdd" == t) a = "/bh_farm/pages/pdd/pdd"; else if ("db" == t) var a = "/bh_farm/pages/treasure/treasure";
            wx.redirectTo({
                url: a
            });
        }
    },
    onShareAppMessage: function() {
        return {
            title: this.data.share.text,
            imageUrl: this.data.share.images,
            path: "bh_farm/pages/index/index?parent_id=" + this.data.share.member_id
        };
    },
    getUserInfo: function(e) {
        if ("getUserInfo:ok" == e.detail.errMsg) {
            var o = {
                action: "register",
                contr: "home",
                token: wx.getStorageSync("token"),
                encryptedData: e.detail.encryptedData,
                iv: e.detail.iv
            };
            a.default.request(o, function(e) {
                t.onReady(), t.showInviteRed();
            });
        }
    }
});